package com.example.fastgithub.utils;

public class UrlUtils {
    private static final String patten="http(s)?://github.com(/[\\w- ./?%&=]*)?";
    private static final String addString=".com.cnpmjs.org/";
    private static final String splitString=".com/";
    private static boolean isRightUrl(String url){
        if(url.matches(patten)){
            return true;
        }
        return false;
    }
    public static String changeUrl(String url){
        if(isRightUrl(url)){
            return StringSplit(url,splitString);
        }
        return url;
    }
    private static String StringSplit(String url,String split){
        if(url.contains(splitString)){
            String[] urls= url.split(split);
           return urls[0]+addString+urls[1];
        }
        return url;
    }
}
